<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>canvas text</title>
  <style>
    body{
      text-align: center;
    }
    #canvas{
      background-color: #cccccc;
    }
  </style>
</head>
<body>
  <h3>演示 canvas文本</h3>
  <canvas id="canvas" width="500" height="400"></canvas>

  <script>
    var canvas = document.getElementById("canvas");
    var ctx = canvas.getContext("2d");

    ctx.textBaseline = "top"; //bottom alphabetic
    ctx.font = "20px SimHei"
    ctx.fillText("实心abcxyz", 0, 0);
    ctx.strokeText("空心abcxyz", 0, 30);

    

  </script>
</body>
</html>